<!DOCTYPE html>
<html lang=en>
<head>
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta name="description" content="centOS安装操作Docker1.安装与卸载docker安装docker123456789101112（1）安装需要的软件包	yum install -y yum-utils device-mapper-persistent-data lvm2（2）设置yum源	yum-config-manager --add-repo https:&#x2F;&#x2F;download.docker.com&#x2F;linux&#x2F;cen">
<meta name="keywords" content="Linux,运维">
<meta property="og:type" content="article">
<meta property="og:title" content="centOS安装操作Docker">
<meta property="og:url" content="http:&#x2F;&#x2F;yoursite.com&#x2F;2019&#x2F;09&#x2F;21&#x2F;centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker&#x2F;index.html">
<meta property="og:site_name" content="ECIN&#39;S BLOG">
<meta property="og:description" content="centOS安装操作Docker1.安装与卸载docker安装docker123456789101112（1）安装需要的软件包	yum install -y yum-utils device-mapper-persistent-data lvm2（2）设置yum源	yum-config-manager --add-repo https:&#x2F;&#x2F;download.docker.com&#x2F;linux&#x2F;cen">
<meta property="og:locale" content="en">
<meta property="og:updated_time" content="2019-11-02T06:56:06.000Z">
<meta name="twitter:card" content="summary">
    
    
        
          
              <link rel="shortcut icon" href="/images/favicon.ico">
          
        
        
          
            <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
          
        
        
          
            <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
          
        
    
    <!-- title -->
    <title>centOS安装操作Docker</title>
    <!-- styles -->
    <link rel="stylesheet" href="/css/style.css">
    <!-- persian styles -->
    
      <link rel="stylesheet" href="/css/rtl.css">
    
    <!-- rss -->
    
    
</head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        <li><a class="icon" href="/2019/09/26/Linux%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/"><i class="fas fa-chevron-left" aria-hidden="true" onmouseover="$('#i-prev').toggle();" onmouseout="$('#i-prev').toggle();"></i></a></li>
        
        
        <li><a class="icon" href="/2019/09/21/CentOS%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8%20%E5%9F%BA%E7%A1%80%E6%93%8D%E4%BD%9C%20%E8%BF%9C%E7%A8%8B%E8%BF%9E%E6%8E%A5MySql/"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>
      </ul>
      <span id="i-prev" class="info" style="display:none;">Previous post</span>
      <span id="i-next" class="info" style="display:none;">Next post</span>
      <span id="i-top" class="info" style="display:none;">Back to top</span>
      <span id="i-share" class="info" style="display:none;">Share post</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/" target="_blank" rel="noopener"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&text=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&title=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&is_video=false&description=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=centOS安装操作Docker&body=Check out this article: http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/" target="_blank" rel="noopener"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&title=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&title=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&title=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&title=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&name=centOS安装操作Docker&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&t=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#centOS安装操作Docker"><span class="toc-number">1.</span> <span class="toc-text">centOS安装操作Docker</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#1-安装与卸载docker"><span class="toc-number">1.0.1.</span> <span class="toc-text">1.安装与卸载docker</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#3-使用docker，包含命令"><span class="toc-number">1.0.2.</span> <span class="toc-text">3.使用docker，包含命令</span></a></li></ol></li></ol></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        centOS安装操作Docker
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">ECIN'S BLOG</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2019-09-20T19:20:27.000Z" itemprop="datePublished">2019-09-21</time>
        
      
    </div>


      

      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link" href="/tags/Linux/" rel="tag">Linux</a>, <a class="tag-link" href="/tags/%E8%BF%90%E7%BB%B4/" rel="tag">运维</a>
    </div>


    </div>
  </header>
  

  <div class="content" itemprop="articleBody">
    <h4 id="centOS安装操作Docker"><a href="#centOS安装操作Docker" class="headerlink" title="centOS安装操作Docker"></a>centOS安装操作Docker</h4><h6 id="1-安装与卸载docker"><a href="#1-安装与卸载docker" class="headerlink" title="1.安装与卸载docker"></a>1.安装与卸载docker</h6><pre><code>安装docker</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">（1）安装需要的软件包</span><br><span class="line">	yum install -y yum-utils device-mapper-persistent-data lvm2</span><br><span class="line">（2）设置yum源</span><br><span class="line">	yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo</span><br><span class="line">（3）安装</span><br><span class="line">	yum install -y docker-ce</span><br><span class="line">(4) 配置阿里云加速器，在etc/docker/daemon.json文件中加入</span><br><span class="line">	&#123;</span><br><span class="line"></span><br><span class="line">  &quot;registry-mirrors&quot;: [&quot;https://wghlmi3i.mirror.aliyuncs.com&quot;]</span><br><span class="line">	</span><br><span class="line">	&#125;</span><br></pre></td></tr></table></figure>

<pre><code>卸载docker</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">yum remove docker docker-common docker-selinux docker-engine</span><br><span class="line">查询安装的docker：yum list installed | grep docker</span><br><span class="line">删除：yum remove ***</span><br></pre></td></tr></table></figure>



<h6 id="3-使用docker，包含命令"><a href="#3-使用docker，包含命令" class="headerlink" title="3.使用docker，包含命令"></a>3.使用docker，包含命令</h6><pre><code>启动docker服务</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">service docker start或者</span><br><span class="line">systemctl start docker.service</span><br></pre></td></tr></table></figure>

<pre><code>重启docker服务</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">service docker restart</span><br></pre></td></tr></table></figure>

<pre><code>使用帮助</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker --help</span><br></pre></td></tr></table></figure>



<pre><code>列出本机所有镜像（包含中间映像层）</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker images -a</span><br></pre></td></tr></table></figure>

<pre><code>![1557586854457](C:\Users\NICE\AppData\Roaming\Typora\typora-user-images\1557586854457.png)</code></pre><p>​    </p>
<pre><code>列出镜像id</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker images -q</span><br></pre></td></tr></table></figure>

<pre><code>列出镜像（包含中间映像层）id</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker images -qa</span><br></pre></td></tr></table></figure>

<pre><code>查找可安装镜像，如docker search tomcat</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker search ***</span><br></pre></td></tr></table></figure>

<pre><code>删除镜像，如hello-world</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker rmi *******</span><br></pre></td></tr></table></figure>

<pre><code>强制删除镜像</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker rmi -f ***********</span><br></pre></td></tr></table></figure>

<pre><code>通过交互模式启动并进入容器，退出ctrl+D</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -i -t centos</span><br></pre></td></tr></table></figure>

<pre><code>后台启动容器</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -d -i centos</span><br></pre></td></tr></table></figure>

<pre><code>查看正在运行的容器</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker ps</span><br></pre></td></tr></table></figure>

<pre><code>进入后台的容器</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker exec centos /bin/bash</span><br></pre></td></tr></table></figure>

<pre><code>关闭后台的容器</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker stop centos</span><br></pre></td></tr></table></figure>

<pre><code>run命令的参数解释</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br></pre></td><td class="code"><pre><span class="line">Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]  </span><br><span class="line"> </span><br><span class="line">  -d, --detach=false         指定容器运行于前台还是后台，默认为false   </span><br><span class="line">  -i, --interactive=false   打开STDIN，用于控制台交互  </span><br><span class="line">  -t, --tty=false            分配tty设备，该可以支持终端登录，默认为false  </span><br><span class="line">  -u, --user=&quot;&quot;              指定容器的用户  </span><br><span class="line">  -a, --attach=[]            登录容器（必须是以docker run -d启动的容器）</span><br><span class="line">  -w, --workdir=&quot;&quot;           指定容器的工作目录 </span><br><span class="line">  -c, --cpu-shares=0        设置容器CPU权重，在CPU共享场景使用  </span><br><span class="line">  -e, --env=[]               指定环境变量，容器中可以使用该环境变量  </span><br><span class="line">  -m, --memory=&quot;&quot;            指定容器的内存上限  </span><br><span class="line">  -P, --publish-all=false    指定容器暴露的端口  </span><br><span class="line">  -p, --publish=[]           指定容器暴露的端口 </span><br><span class="line">  -h, --hostname=&quot;&quot;          指定容器的主机名  </span><br><span class="line">  -v, --volume=[]            给容器挂载存储卷，挂载到容器的某个目录  </span><br><span class="line">  --volumes-from=[]          给容器挂载其他容器上的卷，挂载到容器的某个目录</span><br><span class="line">  --cap-add=[]               添加权限，权限清单详见：http://linux.die.net/man/7/capabilities  </span><br><span class="line">  --cap-drop=[]              删除权限，权限清单详见：http://linux.die.net/man/7/capabilities  </span><br><span class="line">  --cidfile=&quot;&quot;               运行容器后，在指定文件中写入容器PID值，一种典型的监控系统用法  </span><br><span class="line">  --cpuset=&quot;&quot;                设置容器可以使用哪些CPU，此参数可以用来容器独占CPU  </span><br><span class="line">  --device=[]                添加主机设备给容器，相当于设备直通  </span><br><span class="line">  --dns=[]                   指定容器的dns服务器  </span><br><span class="line">  --dns-search=[]            指定容器的dns搜索域名，写入到容器的/etc/resolv.conf文件  </span><br><span class="line">  --entrypoint=&quot;&quot;            覆盖image的入口点  </span><br><span class="line">  --env-file=[]              指定环境变量文件，文件格式为每行一个环境变量  </span><br><span class="line">  --expose=[]                指定容器暴露的端口，即修改镜像的暴露端口  </span><br><span class="line">  --link=[]                  指定容器间的关联，使用其他容器的IP、env等信息  </span><br><span class="line">  --lxc-conf=[]              指定容器的配置文件，只有在指定--exec-driver=lxc时使用  </span><br><span class="line">  --name=&quot;&quot;                  指定容器名字，后续可以通过名字进行容器管理，links特性需要使用名字  </span><br><span class="line">  --net=&quot;bridge&quot;             容器网络设置:</span><br><span class="line">				                bridge 使用docker daemon指定的网桥     </span><br><span class="line">				                host 	//容器使用主机的网络  </span><br><span class="line">				                container:NAME_or_ID  &gt;//使用其他容器的网路，共享IP和PORT等网络资源  </span><br><span class="line">				                none 容器使用自己的网络（类似--net=bridge），但是不进行配置 </span><br><span class="line">  --privileged=false         指定容器是否为特权容器，特权容器拥有所有的capabilities  </span><br><span class="line">  --restart=&quot;no&quot;             指定容器停止后的重启策略:</span><br><span class="line">				                no：容器退出时不重启  </span><br><span class="line">				                on-failure：容器故障退出（返回值非零）时重启 </span><br><span class="line">				                always：容器退出时总是重启  </span><br><span class="line">  --rm=false                 指定容器停止后自动删除容器(不支持以docker run -d启动的容器)  </span><br><span class="line">  --sig-proxy=true           设置由代理接受并处理信号，但是SIGCHLD、SIGSTOP和SIGKILL不能被代理</span><br></pre></td></tr></table></figure>

<pre><code>docker常用十大命令</code></pre><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><span class="line">1、 从官网拉取镜像</span><br><span class="line"> </span><br><span class="line">docker pull &lt;镜像名:tag&gt;</span><br><span class="line">如：docker pull centos(拉取centos的镜像到本机)</span><br><span class="line"> </span><br><span class="line">2、搜索在线可用镜像名</span><br><span class="line"> </span><br><span class="line">docker search &lt;镜像名&gt;</span><br><span class="line">如：docker search centos( 在线查找centos的镜像)</span><br><span class="line"> </span><br><span class="line">3、查询所有的镜像，默认是最近创建的排在最上</span><br><span class="line"> </span><br><span class="line">docker images</span><br><span class="line"> </span><br><span class="line">4、查看正在运行的容器</span><br><span class="line"> </span><br><span class="line">docker ps</span><br><span class="line"> </span><br><span class="line">5、删除单个镜像</span><br><span class="line"> </span><br><span class="line">docker rmi -f &lt;镜像ID&gt;</span><br><span class="line"> </span><br><span class="line">6、启动、停止操作</span><br><span class="line"> </span><br><span class="line">docker stop &lt;容器名or ID&gt; #停止某个容器 </span><br><span class="line">docker start &lt;容器名or ID&gt; #启动某个容器 </span><br><span class="line">docker kill &lt;容器名or ID&gt; #杀掉某个容器</span><br><span class="line"> </span><br><span class="line">7、查询某个容器的所有操作记录。</span><br><span class="line"> </span><br><span class="line">docker logs &#123;容器ID|容器名称&#125; </span><br><span class="line"> </span><br><span class="line">8、制作镜像  使用以下命令，根据某个“容器 ID”来创建一个新的“镜像”：</span><br><span class="line"> </span><br><span class="line">docker commit 93639a83a38e  wsl/javaweb:0.1</span><br><span class="line"> </span><br><span class="line">9、启动一个容器</span><br><span class="line"> </span><br><span class="line">docker run -d -p 58080:8080 --name javaweb wsl/javaweb:0.1 /root/run.sh</span><br><span class="line"> </span><br><span class="line">解释：-d：表示以“守护模式”执行/root/run.sh脚本</span><br><span class="line">      -p：表示宿主机与容器的端口映射，此时将容器内部的 8080 端口映射为宿主机的 58080 端口，这样就向外界暴露了 58080 端口，可通过 Docker 网桥来访问容器内部的 8080 端口了。</span><br><span class="line">      -name:为容器命名</span><br><span class="line"> </span><br><span class="line">10、启动docker服务</span><br><span class="line"> </span><br><span class="line">service docker start</span><br></pre></td></tr></table></figure>
  </div>
</article>



        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#centOS安装操作Docker"><span class="toc-number">1.</span> <span class="toc-text">centOS安装操作Docker</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#1-安装与卸载docker"><span class="toc-number">1.0.1.</span> <span class="toc-text">1.安装与卸载docker</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#3-使用docker，包含命令"><span class="toc-number">1.0.2.</span> <span class="toc-text">3.使用docker，包含命令</span></a></li></ol></li></ol></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/" target="_blank" rel="noopener"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&text=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&title=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&is_video=false&description=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=centOS安装操作Docker&body=Check out this article: http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/" target="_blank" rel="noopener"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://getpocket.com/save?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&title=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&title=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&title=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&title=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&name=centOS安装操作Docker&description=" target="_blank" rel="noopener"><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=http://yoursite.com/2019/09/21/centOS%E5%AE%89%E8%A3%85%E6%93%8D%E4%BD%9CDocker/&t=centOS安装操作Docker" target="_blank" rel="noopener"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> Menu</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> TOC</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> Share</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> Top</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
  <div class="footer-left">
    Copyright &copy; 2020 ECIN520
  </div>
  <div class="footer-right">
    <nav>
      <ul>
         
          <li><a href="/">Home</a></li>
         
          <li><a href="/about/">About</a></li>
         
          <li><a href="/archives/">Writing</a></li>
         
          <li><a href="/projects_url">Projects</a></li>
        
      </ul>
    </nav>
  </div>
</footer>

    </div>
    <!-- styles -->
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
<link rel="stylesheet" href="/lib/justified-gallery/css/justifiedGallery.min.css">

    <!-- jquery -->
<script src="/lib/jquery/jquery.min.js"></script>
<script src="/lib/justified-gallery/js/jquery.justifiedGallery.min.js"></script>
<!-- clipboard -->

  <script src="/lib/clipboard/clipboard.min.js"></script>
  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"Copy to clipboard!\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "Copied!");
      e.clearSelection();
    })
  })
  </script>

<script src="/js/main.js"></script>
<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

<!-- Disqus Comments -->


</body>
</html>
